﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using InterfaceWinForm;
using CamadaAcessoDadosPostgresql;
using Entidades;
using ControlesPadroes;

namespace InterfaceWinForm
{
    public partial class UsuarioBrowse : BrowsePadrao
    {
        

    
        public UsuarioBrowse()
        {
            
            base.OpenBrowse = EnumOpenBrowse.Listagem;
            base.InicializarBrowse();
        }

        protected override void CarregarGrid()
        {
            try
            {
                radGridView1.DataSource = new UsuarioWork().GetTodos();
                radGridView1.AutoGenerateColumns = true;
            }
            catch (Exception ex)
            {
                base.RetornarInformacao("Erro", ex.Message);
            }
        }

        protected override Object CriarObjeto()
        {
            Usuario usuario = new Usuario();


            try
            {
                if (!(radGridView1.CurrentRow == null))
                    usuario = new UsuarioWork().Get(int.Parse(radGridView1.CurrentRow.Cells["idusuario"].Value.ToString()));
            }
            catch (Exception ex)
            {
                base.RetornarInformacao("Erro", ex.Message);
            }
            
            return usuario;
            

        }
        protected override bool InformarForm(Object pObjeto, EnumOpenForm pOpenform)
        {
            new UsuarioForm(pObjeto, pOpenform).ShowDialog();

            return true;
        }


  
    }
}
